//
//  LoginTest.m
//  UITestAPPTests
//
//  Created by GMS on 2021/1/29.
//

#import <KIF/KIF.h>

@interface LoginTest : KIFTestCase

@end

@implementation LoginTest

// MARK: 每个测试用例前准备
- (void)beforeEach {
}

// MARK: 每个测试用例后恢复状态
- (void)afterEach {
    if ([tester tryFindingViewWithAccessibilityLabel:@"登录页->退出" error:nil]) {
        [tester tapViewWithAccessibilityLabel:@"登录页->退出"];
    }
}

// MARK: 测试用例 账号为空 密码为空 正常账号密码
- (void)testLogin {
    
    if (![tester tryFindingViewWithAccessibilityLabel:@"登录页->账号" error:nil]) {
        return;
    }
    
    // 账号为空
    [tester clearTextFromViewWithAccessibilityLabel:@"登录页->账号"];
    [tester clearTextFromAndThenEnterText:@"123456" intoViewWithAccessibilityLabel:@"登录页->密码"];
    [tester tapViewWithAccessibilityLabel:@"登录页->登录"];
    
    // 密码为空
    [tester clearTextFromAndThenEnterText:@"admin" intoViewWithAccessibilityLabel:@"登录页->账号"];
    [tester clearTextFromViewWithAccessibilityLabel:@"登录页->密码"];
    [tester tapViewWithAccessibilityLabel:@"登录页->登录"];
    
    // 正常
    [tester clearTextFromAndThenEnterText:@"admin" intoViewWithAccessibilityLabel:@"登录页->账号"];
    [tester clearTextFromAndThenEnterText:@"123456" intoViewWithAccessibilityLabel:@"登录页->密码"];
    [tester tapViewWithAccessibilityLabel:@"登录页->登录"];
    
}

@end
